package cmd

import (
	"github.com/chmodke/gitmm/config"
	"github.com/chmodke/gitmm/util"
	"os"
	"path/filepath"
)

var Config *config.Config
var withOutConfig = []string{"--help", "-h", "version", "-v", "config"}

func init() {
	if len(os.Args) >= 2 && util.ContainsAny(withOutConfig, os.Args[1]) {
		return
	}
	Config = config.LoadConfig()
}

func InitWorkSpace(workDir string) {
	workPath, err := util.GetWorkDir(workDir)
	if err != nil {
		return
	}

	config.WriteCfg(Config, filepath.Join(workPath, ".gitmm"))
}
